package com.duowei.diandan.db.entry;

import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;

import org.joda.time.LocalDateTime;

/**
 * 点餐餐桌
 */
@Entity
public class Dccz {
    @PrimaryKey(autoGenerate = true)
    private long id;

    private String zh;
    private String yhmc;
    private String by1;
    private String by2;
    private Float by3;
    private Float by4;
    private LocalDateTime by5;

    public Dccz() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getZh() {
        return zh;
    }

    public void setZh(String zh) {
        this.zh = zh;
    }

    public String getYhmc() {
        return yhmc;
    }

    public void setYhmc(String yhmc) {
        this.yhmc = yhmc;
    }

    public String getBy1() {
        return by1;
    }

    public void setBy1(String by1) {
        this.by1 = by1;
    }

    public String getBy2() {
        return by2;
    }

    public void setBy2(String by2) {
        this.by2 = by2;
    }

    public Float getBy3() {
        return by3;
    }

    public void setBy3(Float by3) {
        this.by3 = by3;
    }

    public Float getBy4() {
        return by4;
    }

    public void setBy4(Float by4) {
        this.by4 = by4;
    }

    public LocalDateTime getBy5() {
        return by5;
    }

    public void setBy5(LocalDateTime by5) {
        this.by5 = by5;
    }

    public static String deleteByBy1Sql(String by1) {
        return "DELETE FROM dccz WHERE by1 = '" + by1 + "'|";
    }

    public static String insertSql(Dccz dccz) {
        return "BEGIN " +
                "   IF NOT EXISTS (SELECT * FROM DCCZ " +
                "                   WHERE by1 = '" + dccz.getBy1() + "')" +
                "   BEGIN " +
                "       INSERT INTO DCCZ (ZH, YHMC, BY1, BY2, BY3, BY4, BY5) " +
                " VALUES ('" + dccz.getZh() + "', '" + dccz.getYhmc() + "', '" + dccz.getBy1() + "', '" + dccz.getBy2() + "', null, null, '" + dccz.getBy5().toString("yyyy-MM-dd HH:mm:ss") + "') " +
                "   END " +
                "END|";
    }
}
